<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>数据查看</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">

</head>
<%@include file="../include/header.jsp" %>
<body>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <section>
        <input type="hidden" id="endTime"
               value="<fmt:formatDate value='${activity.endTime}' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
        <div class="section-main">
            <%--直接付款--%>
            <div class="layui-tab layui-tab-brief mt20">
                <ul class="layui-tab-title">
                    <li class="" id="funding">众筹<span id="total_1" class="pl5">${crowdfundNum}</span>人
                    </li>
                    <li class="" id="representing">联合发起<span id="total_0"
                                                             class="pl5">${activity.representNum}</span>人
                    </li>
                    <li class="layui-this" id="directPay">直接付款<span id="total_2"
                                                                    class="pl5">${empty list?0:list.size()}</span>人
                    </li>
                    <li class="" id="transfer">转入<span id="total_3" class="pl5">${transferNum}</span>人
                    </li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item  layui-show">
                        <form class="layui-form" action="${ctx}/activity/activity/zcDirectPayList.do?id=${activity.id}"
                              id="myForm" method="post">
                            <input type="hidden" name="pageNo" id="pageNo"/>
                            <div class="f-search-bar">
                                <div class="search-container">
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label class="search-form-lable">姓名</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="authorName" autocomplete="off"
                                                       class="layui-input" value="${projectWithAuthor.authorName}"
                                                       placeholder="姓名">
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">联系电话</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="authorMobile" autocomplete="off"
                                                       class="layui-input" value="${projectWithAuthor.authorMobile}"
                                                       placeholder="联系电话">
                                            </div>
                                        </li>

                                        <li class="form-item">
                                            <label class="search-form-lable">支付状态</label>
                                            <div class="layui-input-inline">
                                                <select name="isSuccess">
                                                    <option value="">全部</option>
                                                    <option value="0" ${projectWithAuthor.isSuccess == 0 ? 'selected="selected"' : ''}>
                                                        未支付
                                                    </option>
                                                    <option value="1" ${projectWithAuthor.isSuccess == 1 ? 'selected="selected"' : ''}>
                                                        支付成功
                                                    </option>
                                                    <option value="3" ${projectWithAuthor.isSuccess == 3 ? 'selected="selected"' : ''}>
                                                        退款中
                                                    </option>
                                                    <option value="4" ${projectWithAuthor.isSuccess == 4 ? 'selected="selected"' : ''}>
                                                        退款成功
                                                    </option>
                                                    <option value="5" ${projectWithAuthor.isSuccess == 5 ? 'selected="selected"' : ''}>
                                                        退款失败
                                                    </option>
                                                </select>
                                            </div>
                                        </li>
                                        <li class="form-item-inline">
                                            <div class="sub-btns">
                                                <a class="layui-btn layui-btn-danger"
                                                   href="javascript:submitFunction('#myForm')">查询</a>
                                                <a class="layui-btn layui-btn-normal"
                                                   href="javascript:resetFunction('#myForm')">重置</a>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </form>
                        <form class="layui-form" action="${ctx}/activity/activity/directPayListExport.do"
                              id="exportForm" method="post">
                            <input type="hidden" name="id" value="${activity.id}">
                        </form>
                        <div class="my-act-list-content">
                            <ul class="num">
                                <div class="l">
                                    <li class="f16">直接付款 <span class="red">${page.totalCount}</span> 人</li>
                                </div>
                                <div class="r">
                                    <li style="cursor: pointer;" class="r">
                                        <c:if test="${empty zipUrl}">
                                            <a class="layui-btn layui-btn-danger layui-btn-sm"
                                               id="btnExport">导出EXCEL</a>
                                        </c:if>
                                        <c:if test="${not empty zipUrl}">
                                            <a class="layui-btn layui-btn-danger layui-btn-sm" id="btnExport">重新生成EXCEL</a>
                                            <c:if test="${not empty zipUploadTime}">
                                                <a class="layui-btn layui-btn-danger layui-btn-sm" target="_blank"
                                                   title="上次生成时间：${zipUploadTime}" href="${zipUrl}">点击下载</a>
                                            </c:if>
                                            <c:if test="${empty zipUploadTime}">
                                                <a class="layui-btn layui-btn-danger layui-btn-sm" target="_blank" href="${zipUrl}">点击下载</a>
                                            </c:if>
                                        </c:if>
                                    </li>
                                </div>
                                <p class="cl"></p>
                            </ul>
                            <div class="cl">
                                <table class="layui-table">
                                    <colgroup>
                                        <col>
                                        <col>
                                        <col>
                                        <col>
                                        <col>
                                        <col>
                                        <col>
                                        <col>
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>姓名</th>
                                        <th>公司</th>
                                        <th>区域</th>
                                        <th>职务</th>
                                        <th>联系电话</th>
                                        <th>付款金额</th>
                                        <th>状态</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach var="directPay" items="${list}">
                                        <tr>
                                            <td class="table-member"
                                                onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${directPay.authorId}','400px','470px')">
                                                <div class="member-cell">
                                                    <div class="member-logo common-img">
                                                        <img src="<c:if test="${directPay.authorLogo != null}">${directPay.authorLogo}?imageMogr2/auto-orient/crop/126x126</c:if>"
                                                             alt="" onerror="txz.errImg(this)"
                                                             onload="txz.imgLoad(this)">
                                                    </div>
                                                    <div class="member-name ellipsis-1"><a class="blue"
                                                                                           title="${directPay.authorName}"
                                                                                           href="javascript:void(0);">${directPay.authorName}</a>
                                                    </div>
                                                </div>
                                            </td>
                                            <td>
                                                <div class="dib ellipsis-1"
                                                     title="${directPay.authorCompany}">${directPay.authorCompany}</div>
                                            </td>
                                            <td>
                                                    ${directPay.cityName}
                                            </td>
                                            <td>
                                                    ${directPay.authorJobTitle}
                                            </td>
                                            <td>
                                                    ${directPay.authorMobile}
                                            </td>

                                            <td>
                                                <a href="javascript:void(0);"
                                                   class="blue ${directPay.actualAmount > 0 ||directPay.isSuccess == 4 ? 'favorerNum' : ''} count-num"
                                                   data-id="${directPay.id}"
                                                   data-name="${directPay.authorName}">${directPay.actualAmount}</a>
                                            </td>
                                            <td>
                                                <c:choose>
                                                    <c:when test="${directPay.isSuccess==0}">未支付</c:when>
                                                    <c:when test="${directPay.isSuccess==1}">支付成功</c:when>
                                                    <c:when test="${directPay.isSuccess==3}">退款中</c:when>
                                                    <c:when test="${directPay.isSuccess==4}">退款成功</c:when>
                                                    <c:when test="${directPay.isSuccess==5}">退款失败</c:when>
                                                </c:choose>
                                            </td>
                                            <td class="tb-opts">
                                                <div class="comm-opts">
                                                    <a class="qr-btn" href="javascript:txz.openQrDialog({
                                                            title:'扫码二维码可预览分享',
                                                            detailList:[
                                                               {
                                                               title:'直接付款众筹详情',
                                                               url:'${directPay.qrCodeUrl}',
                                                               link: '${directPay.url}'
                                                               }
                                                            ]
                                                            })"> 二维码</a>
<%--                                                    <c:if test="${directPay.actualAmount > 0 && (directPay.isSuccess == 1 || directPay.isSuccess == 5)}">
                                                        <a href="javascript:refund('${directPay.supportId}');"
                                                           target="_self">退款</a>
                                                    </c:if>--%>
                                                    <a href="javascript:revise('${directPay.id}')"
                                                       target="_self">校正</a>
                                                    <c:if test="${directPay.actualAmount <= 0}">
                                                        <a href="javascript:txz.deleteObject('确定删除该众筹', '${ctx}/crowdfund/project/delete.do?id=${directPay.id}');"
                                                           target="_self">
                                                            删除
                                                        </a>
                                                    </c:if>
                                                </div>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div id="page_content" class="page-container"></div>
                    </div>
                    <div class="layui-tab-item">

                    </div>
                </div>
            </div>
        </div>
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript">
    var laytpl = null;
    var laypage = null;
    var element = null;
    txz.initHeader({
        nav: [{
            name: '众筹项目管理',
            href: '${ctx}/activity/activity/zcActivityList.do',
        }, {
            name: '${activity.title}'
        }, {
            name: '数据查看',
            curr: true
        }],
        info: '<span class="f12">共<b>${page.totalCount}</b>条记录',
        btns: [{
            type: 'back'
        }]
    });

    //校正功能
    function revise(id) {
        $.post("${ctx}/crowdfund/project/revise.do", {
            id: id
        }, function (data) {
            if (data.success == true) {
                util.layerAlertSuccess("校正成功", function () {
                    window.location.reload();
                })
            } else {
                util.layerAlertError("校正失败")
            }
        });
    }

    $(function () {

        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['laytpl', 'laypage', 'element'], function () {
            laytpl = layui.laytpl;
            laypage = layui.laypage;
            element = layui.element;
            element.on('tab', function (data) {
                if (data.index == 0) {//众筹
                    window.location.href = "${ctx}/activity/activity/zcCrowdfundList.do?id=${activity.id}";
                } else if (data.index == 1) {//联合发起
                    window.location.href = "${ctx}/activity/activity/zcRepresentList.do?id=${activity.id}";
                } else if (data.index == 2) {//直接付款
                    window.location.href = "${ctx}/activity/activity/zcDirectPayList.do?id=${activity.id}";
                } else if (data.index == 3) {
                    window.location.href = "${ctx}/activity/activity/zcShiftToPeopleList.do?id=${activity.id}";
                }
            });
        });
        $('.crowdfundNum').click(function () {
            var projectId = this.dataset.id;
            var name = this.dataset.name;
            window.location.href = '${ctx}/crowdfund/support/dpListForProjectId.do?id=${activity.id}&projectId=' + projectId;
        });

        $('.favorerNum').click(function () {
            var projectId = this.dataset.id;
            var name = this.dataset.name;
            window.location.href = '${ctx}/crowdfund/support/dpListForProjectId.do?id=${activity.id}&projectId=' + projectId;
        });

        $('.actualAmount').click(function () {
            var projectId = this.dataset.id;
            var name = this.dataset.name;
            window.location.href = '${ctx}/crowdfund/support/dpListForProjectId.do?id=${activity.id}&projectId=' + projectId;
        });

        $("#btnExport").click(function () {
            layer.confirm('确认要导出Excel吗?', {
                icon: 3,
                title: '系统提示'
            }, function (index) {
                //loading层
                var loadIndex = layer.load(1, {
                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                });
                $.post("${ctx}/activity/activity/directPayListExport.do?id=${activity.id}", $("#myForm").serialize(), function (data) {
                    console.log('start : ' + new Date().getTime());
                    layer.close(loadIndex);
                    if (data.success) {
                        util.layerAlertSuccess("正在导出中请耐心等待，稍后请点击下载按钮即可下载文件。")
                    } else {
                        util.layerAlertError("操作失败");
                    }
                });
                top.layer.close(index);
            });
        });
    })

    util.initWebSocket(function (event) {
        console.log(event.data);
        console.log('end : ' + new Date().getTime());
        if (event.data) {
            util.layerAlertSuccess(event.data, function () {
                var title = "\"${activity.title}\"";
                var substr = event.data.substring(0, event.data.indexOf('众筹直接付款人员导出成功了'));
                if (title == substr) {
                    location.reload();
                }
            })
        }
    });
</script>
</body>
</html>
